<template>
    <BasicModal v-bind="$attrs" @register="register" :title="getTitle"  width="950px" @ok="handleSubmit">
        <a-spin :spinning="loading" size="large" tip="Loading...">
            <a-form ref="formRef" class="antd-modal-form">
                <p style="text-align: center;">
                    <span style="width: 35%;text-align: center;font: 1.7em sans-serif;">{{ formData.labItemsReportPage.samName }}</span><br>
                    <span style="width: 35%;text-align: center;font: 1.7em sans-serif;">检验结果报告单</span>
                </p>
                <table id="items" cellspacing="1" style="width: 100%;height: 150px;border: 1px solid #a8aeb2;">
                    <tr class="tr">
                        <th class="thC">依据标准:</th>
                        <th class="thE" :colspan="3">{{ formData.labItemsReportPage.basisName }}</th>
                    </tr>
                    <tr class="tr">
                        <th class="thC">样品编号:</th>
                        <td class="thE">{{ formData.labItemsReportPage.samNum }}</td>
                        <td class="thC">报告编号:</td>
                        <td class="thE">{{ formData.labItemsReportPage.reportNum }}</td>
                    </tr>
                    <tr class="tr">
                        <th class="thC">填报日期:</th>
                        <td class="thE">{{ formData.labItemsReportPage.reportDate }}</td>
                        <td class="thC"></td>
                        <td class="thE"></td>
                    </tr>
                </table>
                <!--项目列表-->
                <labItemsTable ref="registerItemsTable"  :labEntrustItemsList="formData.labItemsReportPage.labEntrustItemsList"></labItemsTable>
                <table id="items" cellspacing="1" style="width: 100%;height: 250px;border: 1px solid #a8aeb2;">
                    <tr class="tr">
                        <th class="thB">检验结论</th>
                        <th style="width: 20%;text-align: left;border: 1px solid #a8aeb2;font: 1.1em sans-serif;" colspan="5">{{ formData.labItemsReportPage.reportConcl }}</th>
                    </tr>
                    <tr class="tr">
                        <th class="thB">备注</th>
                        <th style="width: 20%;text-align: left;border: 1px solid #a8aeb2;font: 1.1em sans-serif;" colspan="5">{{ formData.labItemsReportPage.remark }}</th>
                    </tr>
                    <tr style="height: 30px;border: 1px solid #a8aeb2;">
                        <th class="thB">批准人</th>
                        <th style="width: 20%;text-align: center;border: 1px solid #a8aeb2;font: 1.1em sans-serif;">{{ formData.labItemsReportPage.ratifyName }}</th>
                        <th class="thB">审核人</th>
                        <th style="width: 20%;text-align: center;border: 1px solid #a8aeb2;font: 1.1em sans-serif;">{{ formData.labItemsReportPage.auditName }}</th>
                        <th class="thB">主检人</th>
                        <th style="width: 20%;text-align: center;border: 1px solid #a8aeb2;font: 1.1em sans-serif;">{{ formData.labItemsReportPage.checkName }}</th>
                    </tr>
                </table>
            </a-form>
        </a-spin>
    </BasicModal>
</template>
  
<script lang="ts" setup>
import { BasicModal, useModalInner } from '/@/components/Modal';
import { ref, reactive } from 'vue';
import labItemsTable from './LabCheckItemsTable.vue';
import { getReportReviewData } from './LabItemReportList.api';
// import { useMessage } from '/@/hooks/web/useMessage';
// const { createMessage } = useMessage();


const registerItemsTable = ref();
const formRef = ref();
const emit = defineEmits(['success']);
const loading = ref(true);
const getTitle = ref('检验结果报告');
const formData = reactive<Record<string, any>>({
    labItemsReportPage:[{
        id: "",
        samName: "",
        samNum:"",
        basisName:"",
        basisNum:"",
        reportNum:"",
        reportDate:null,
        reportConcl:"",
        remark:"",
        taskId:"",
        checkId:"",
        checkName:"",
        auditId:"",
        auditName:"",
        ratifyId:"",
        ratifyName:"",
        labEntrustItemsList: [],
    }],
    labItemRecordPageList:[],
});


const [register, { setModalProps, closeModal }] = useModalInner(async (data) => {
    setModalProps({
        minHeight: 800,
    });
    let params = {
        entrustId:  data.record.id,
    };
    await getReportReviewData(params).then((res) => {
        Object.assign(formData, res);
        console.log(formData);
    }).finally(() => {
        loading.value = false
    })
});

//提交表单数据
async function handleSubmit() {
    // formData.auditId = formData.auditId;
    // formData.auditName = formData.auditName;
    // if ((formData.auditName != "" && formData.auditName != null) && (formData.ratifyName != "" && formData.ratifyName != null)) {
    //     // console.log(formData);
    //     await saveOrUpdateData(formData).then((res) => {
    //         createMessage.success(res.message);
    //     }).finally(()=>{
            closeModal();
    //         emit('success');
    //     });
    // } else {
    //     createMessage.warning("请选择批准和审核人员!");
    // }

}


</script>
  
<style scoped>
.header {
    line-height: 35px;
    background-color: #f2f2f2;
    color: #666;
}


.tr {
    height: 50px;
    border: 1px solid #a8aeb2;
}
.thA {
    width: 75%;
    text-align: center;
    border: 1px solid #a8aeb2;
    font: 1.1em sans-serif;
}
.thB {
    width: 15%;
    text-align: center;
    border: 1px solid #a8aeb2;
    font: 1.1em sans-serif;
}

.thC {
    width: 20%;
    text-align: center;
    border: 1px solid #a8aeb2;
    font: 1.1em sans-serif;
}

.thD {
    width: 80%;
    text-align: center;
    border: 1px solid #a8aeb2;
    font: 1.1em sans-serif;
}

.thE {
    width: 30%;
    text-align: left;
    border: 1px solid #a8aeb2;
    font: 1.1em sans-serif;
}

.input {
    width: 100%;
    height: 100%;
    border: none;
    background-color: inherit;
    outline: none;
    border-bottom: none;
    font: 1em sans-serif;
}
</style>